home *** CD-ROM | disk | FTP | other *** search
- class SideScroller.BasicObject extends Library.State
- {
- var oLayer;
- var bObjectBlock;
- var bObjectSpecial;
- var mcRef;
- var oGround;
- var oNegativeGround;
- var oPreCalculatedCoords;
- var tmpCoord;
- var nHitDistance;
- function BasicObject(__mcRef, __oLayer)
- {
- super(__mcRef);
- this.oLayer = __oLayer;
- this.bObjectBlock = true;
- this.bObjectSpecial = false;
- this.oLayer.doAddObject(this);
- if(this.mcRef.mcGround != undefined)
- {
- this.oGround = new SideScroller.Ground(this.mcRef.mcGround,this);
- }
- else if(this.mcRef.mcNegativeGround != undefined)
- {
- this.oNegativeGround = new SideScroller.NegativeGround(this.mcRef.mcNegativeGround,this);
- }
- this.setState("Idle");
- }
- function doEnterFrame()
- {
- super.doEnterFrame();
- delete this.oPreCalculatedCoords;
- }
- function doCheckObjects()
- {
- var _loc3_ = this.oLayer.getSpecialObjects(this);
- var _loc5_ = this.oLayer.Ref._x;
- var _loc6_ = this.oLayer.Ref._y;
- var _loc4_ = false;
- var _loc2_ = undefined;
- _loc2_ = 0;
- while(_loc2_ <= _loc3_.length - 1)
- {
- if(_loc3_[_loc2_].Hit.hitTest(this.Hit))
- {
- this.onHitSpecial(_loc3_[_loc2_]);
- _loc3_[_loc2_].onHitSpecial(this);
- }
- _loc2_ = _loc2_ + 1;
- }
- }
- function doDestroy()
- {
- this.oGround.doDestroy();
- this.oNegativeGround.doDestroy();
- delete this.oGround;
- delete this.oNegativeGround;
- delete this.oPreCalculatedCoords;
- delete this.tmpCoord;
- this.mcRef.swapDepths(this.oLayer.getRemoveDepth(this.mcRef));
- this.mcRef.removeMovieClip();
- delete this.mcRef;
- this.oLayer.doRemoveObject(this);
- delete this.oLayer;
- }
- function onHit(__oRef)
- {
- }
- function onHitSpecial(__oRef)
- {
- }
- function get GroundObject()
- {
- if(this.oGround != undefined)
- {
- return this.oGround;
- }
- if(this.oNegativeGround != undefined)
- {
- return this.oNegativeGround;
- }
- }
- function get GroundModifier()
- {
- return this.oGround != undefined || this.oNegativeGround != undefined;
- }
- function get ParentLayer()
- {
- return this.oLayer;
- }
- function get ObjectBlock()
- {
- return this.bObjectBlock;
- }
- function get ObjectSpecial()
- {
- return this.bObjectSpecial;
- }
- function get Hitable()
- {
- return this.mcRef.mcState.mcHit != undefined;
- }
- function get HitDistance()
- {
- return this.nHitDistance;
- }
- function get Hit()
- {
- return this.Ref.mcState.mcHit;
- }
- function get Coord()
- {
- if(this.oPreCalculatedCoords == undefined)
- {
- var _loc2_ = new Object();
- if(this.OnLayerBaseLevel)
- {
- _loc2_.x = this.Ref._x;
- _loc2_.y = this.Ref._y;
- }
- else
- {
- var _loc3_ = Library.Utils.MoreMath.getBoundsCenter(this.mcRef.getBounds(this.ParentLayer.Ref));
- _loc2_.x = _loc3_.x;
- _loc2_.y = _loc3_.y;
- }
- this.oPreCalculatedCoords = _loc2_;
- }
- return this.oPreCalculatedCoords;
- }
- function get OnLayerBaseLevel()
- {
- return this.mcRef._parent == this.ParentLayer.Ref;
- }
- function get Ref()
- {
- return this.mcRef;
- }
- function doLoadStateAction()
- {
- this.doCheckHitZone();
- }
- function doCheckHitZone()
- {
- var _loc4_ = undefined;
- if(this.mcRef.mcState.mcHit != undefined)
- {
- _loc4_ = this.mcRef.mcState.mcHit;
- this.mcRef.mcState.mcHit._visible = false;
- }
- else
- {
- _loc4_ = this.mcRef.mcState;
- }
- var _loc2_ = _loc4_.getBounds(this.mcRef);
- var _loc5_ = Library.Utils.MoreMath.getDistance(0,0,_loc2_.xMin,_loc2_.yMin);
- var _loc6_ = Library.Utils.MoreMath.getDistance(0,0,_loc2_.xMax,_loc2_.yMin);
- var _loc7_ = Library.Utils.MoreMath.getDistance(0,0,_loc2_.xMix,_loc2_.yMax);
- var _loc8_ = Library.Utils.MoreMath.getDistance(0,0,_loc2_.xMax,_loc2_.yMax);
- var _loc3_ = Math.max(_loc5_,_loc6_,_loc7_,_loc8_);
- _loc3_ = Math.abs(_loc3_);
- this.nHitDistance = _loc3_;
- }
- }
-